import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class SplitUsingHashTag {

	 public static void main(String[] args) {
	        SplitUsingHashTag split = new SplitUsingHashTag();
	        split.split();
	    }
	    
	 	public boolean checkGGV(String line){
	 		String[] arr = {"@GandangGabiVice","@@GGViceyungtotoo","@_GGV","@GGV_viceganda","@GGV_Official","@GGVna"
	 				      ,"#ggv","gandanggabivice","gandang gabi vice"};
	 		
	 		for(String x : arr)
	 			if(line.toLowerCase().contains(x.toLowerCase()))
	 				return true;
	 		
	 		return false;
	 	}
	 	
	 	public boolean checkShowtime(String line){
	 		String[] arr = {"@itsShowtimena","@showtimefamily","@itsshowtime_abs","@itshowtimena","#ItsShowtime", "It's Showtime"
	 				     ,"Its Showtime"};
	 		
	 		for(String x : arr)
	 			if(line.toLowerCase().contains(x.toLowerCase()))
	 				return true;
	 		
	 		return false;
	 	}
	 	
	 	public boolean checkEB(String line){
	 		String[] arr = {"EatBulaga", "Eat Bulaga", "EBdabarkads"};
	 		
	 		for(String x : arr)
	 			if(line.toLowerCase().contains(x.toLowerCase()))
	 				return true;
	 		
	 		return false;
	 	}
	 
	    public void split() {
	        
	        File infile = new File("F:/splitTrain/TrainingTweets.csv");
	        
	        String directory = "F:/splitTrain/splitPerShow/";
	        String filename = "splittedTrainingTweets";
	        String extension = ".csv";
	                
	        try {
	            BufferedReader reader = new BufferedReader(new FileReader(infile));
	            BufferedWriter GGVwriter = new BufferedWriter(new FileWriter(directory + "GGV" + extension));
	            BufferedWriter EBwriter = new BufferedWriter(new FileWriter(directory + "EB" + extension));
	            BufferedWriter Showtimewriter = new BufferedWriter(new FileWriter(directory + "Showtime" + extension));
	            
	            String line = reader.readLine();
	            while (line != null) {
	            	
	            	if(checkGGV(line))
	            		GGVwriter.write(line + "\n");
	            	if(checkEB(line))
	            		EBwriter.write(line + "\n");
	            	if(checkShowtime(line))
	            		Showtimewriter.write(line + "\n");
	                
	                line = reader.readLine();
	            }
	            
	            reader.close();
	            GGVwriter.close();
	            EBwriter.close();
	            Showtimewriter.close();
	        }
	        catch (FileNotFoundException e) {
	            e.printStackTrace();
	        }
	        catch (IOException e) {
	            e.printStackTrace();
	        }
	    }
}
